<template>
  <div class="page_box">
    <!-- 搜索区域 开始 -->
    <el-card shadow="never">
      <el-form :inline="true" size="small" :model="formInline" class="demo-form-inline">
        <el-form-item label="名称：">
          <el-input
            v-model="formInline.term"
            placeholder="用户名/账号/手机号"
          ></el-input>
        </el-form-item>
        <el-form-item label="注册时间：">
          <el-date-picker v-model="createTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="系统：">
          <el-select v-model="formInline.region" placeholder="活动区域">
            <el-option label="苹果" value="shanghai"></el-option>
            <el-option label="安卓" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="版本：">
          <el-select v-model="formInline.region" placeholder="活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="渠道：">
          <el-select v-model="formInline.region" placeholder="活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="地区：">
          <el-select v-model="formInline.region" placeholder="活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="getList">查询</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <!-- 搜索区域 end -->

    <div class="link_group">
      <!-- <el-button size="small" type="success" plain>导出excel</el-button> -->
      <el-button size="small" type="success" plain :loading="exportLoading" @click="downExcel">导出excel</el-button>
    </div>

    <!-- 表格 开始 -->
    <div class="table_box">
      <el-table class="tab" size="small" :data="tableData" border stripe>
        <el-table-column type="index" label="序号" width="60" />
        <el-table-column prop="unionId" label="用户ID" show-overflow-tooltip />
        <el-table-column prop="username" label="用户昵称" show-overflow-tooltip />
        <el-table-column prop="gender" label="性别" show-overflow-tooltip>
          <template slot-scope="scope">{{
            scope.row.gender == 0 ? "男" : "女"
          }}</template>
        </el-table-column>
        <el-table-column prop="vipStatus" label="会员" show-overflow-tooltip>
          <template slot-scope="scope">{{
            scope.row.vipStatus == 1||scope.row.vipStatus == 3 ? "是" : "否"
          }}</template>
        </el-table-column>
        <el-table-column prop="city" label="地区" show-overflow-tooltip />
        <el-table-column prop="certDate" label="认证日期" show-overflow-tooltip />
        <el-table-column prop="realName" label="真实姓名" show-overflow-tooltip />
        <el-table-column prop="certNo" label="证件ID" show-overflow-tooltip />
        <el-table-column prop="address" label="操作">
          <template slot-scope="scope">
            <el-link type="primary" @click="lookDetail(scope.row)">详情</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination_list">
        <el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" :current-page.sync="pageNumber" @current-change="getList" @size-change="changePageSize" />
      </div>
    </div>
    <!-- 表格 end -->

    <!-- 弹框 开始 -->
    <glsx-dialog :show="showDialog" title="认证信息详情" @close="closeDialog">
      <div>

        <!-- 单行 开始 -->
        <div class="row_box">
          <div class="cell_box">
            <span class="name">用户ID：</span>
            <div class="txt">{{profile.unionId}}</div>
          </div>
          <div class="cell_box">
            <span class="name">性别：</span>
            <div class="txt">{{profile.gender == 0?'男':'女'}}</div>
          </div>
        </div>
        <!-- 单行 结束 -->
        <!-- 单行 开始 -->
        <div class="row_box">
          <div class="cell_box">
            <span class="name">用户昵称：</span>
            <div class="txt">{{profile.username}}</div>
          </div>
          <div class="cell_box">
            <span class="name">会员：</span>
            <div class="txt">{{vipInfo.status == 1||vipInfo.status == 3?'是':'否'}}</div>
          </div>
        </div>
        <!-- 单行 结束 -->
        <!-- 单行 开始 -->
        <div class="row_box">
          <div class="cell_box">
            <span class="name">认证日期：</span>
            <div class="txt">{{certification.certDate}}</div>
          </div>
        </div>
        <!-- 单行 结束 -->
        <div class="photo_list">
          <div class="img_box">
              <el-image class="img" :src="certification.selfPhoto" fit="cover" :preview-src-list="[certification.selfPhoto]"></el-image>
          </div>
           <div class="img_box">
              <el-image class="img" :src="certification.selfVideo" fit="cover" :preview-src-list="[certification.selfVideo]"></el-image>
          </div>
        </div>

        

      </div>
      <div slot="footer">
        <el-button type="success" plain size="small" @click="closeDialog">关闭</el-button>
      </div>
    </glsx-dialog>
    <!-- 弹框 end -->
  </div>
</template>

<script>
import { GETCERTSEARCH, GETREGISTERINFO,CERTLISTEXPORT } from "@/http/interface";
import { showModal, showToast } from "@/common/util";
import {exportExcel} from '@/common/common'
import GlsxDialog from "@/components/Dialog";
export default {
  components: {
    GlsxDialog,
  },
  data() {
    return {
      formInline: {},
      createTime: [],
      tableData: [],
      pageSize: 10,
      pageTotal: 0,
      pageNumber: 1,
      pageSizes: [10, 20, 30, 40],
      showDialog: false,
      userInfo: {},
      vipInfo: {},
      certification: {},
      photoList: [],
      profile: {},
      exportLoading:false
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    /** 获取参数 */
    getParams() {
      let _this = this;
      let o = JSON.parse(JSON.stringify(_this.formInline)) || {};
      let n = _this.createTime;
      console.log(n);
      if (n && n.length > 0) {
        o.sDate = n[0];
        o.eDate = n[1];
      } else {
        delete o.sDate;
        delete o.eDate;
      }
      o.pageNumber = this.pageNumber;
      o.pageSize = this.pageSize;
      return o;
    },

    /** 每页展示 */
    changePageSize(e) {
      this.pageSize = e;
      this.getList();
    },

    /** 获取列表 */
    getList() {
      let _this = this;
      let oParams = this.getParams();
      GETCERTSEARCH(oParams).then((res) => {
        console.log(res);
        let obj = res.data || {};
        _this.tableData = obj.list || [];
        _this.pageTotal = obj.totalElements;
      });
    },

    /** 封禁 */
    banned(row) {
      showModal({
        message: "确定封禁该用户吗？",
        showCancelButton: true,
        success: function (done) {},
      });
    },

    /** 查看用户详情 */
    lookDetail(row) {
      let _this = this;
      let oParams = {};
      oParams.userId = row.userId;
      _this.showDialog = true;
      GETREGISTERINFO(oParams).then((res) => {
        let obj = res.data || {};
        _this.vipInfo = obj.vip || {};
        _this.certification = obj.certification || {};
        _this.photoList = obj.photoList || {};
        _this.profile = obj.profile || {};
      });
    },

    /** 关闭弹框 */
    closeDialog() {
      this.showDialog = false;
      this.certification = {};
      this.photoList = [];
      this.profile = {};
      this.vipInfo = {};
    },

    /** 导出excel */
    downExcel(){
      let _this = this
      let options = {}
      let _obj = _this.getParams()
      let url = CERTLISTEXPORT
      delete _obj.pageNumber
      delete _obj.pageSize
      _this.exportLoading = true
      options.url = url
      options.data = _obj
      options.fileName = '认证用户列表.xlsx'
      options.method = 'GET'
      options.success = function () {
        _this.exportLoading = false
      }
      options.fail = function () {
        _this.exportLoading = false
      }
      exportExcel(options)
    }

  },
};
</script>

<style lang="scss" scoped>
.link_group {
  margin-top: 10px;
  text-align: right;
}
.avatar {
  height: 30px;
}
.row_box {
  display: flex;
  .cell_box {
    flex: 1;
    display: flex;
    padding: 8px 0;
    .name {
      width: 80px;
      text-align: right;
      font-size: 14px;
    }
  }
}
.photo_list{
  display:flex;
  .img_box{
    flex:1;
    padding:10px;
    height:200px;
    overflow: hidden;
    .img{
      height:100%;
    }
  }
}
</style>
